<template>
  <div class="propertyregist pd30 propertyMaintenance modifyPwd">
    <div class="panelWrap">
      <div class="title flex flexac flexjcsb fs14 cfff fwb pl p-r-20">
        <div>修改密码</div>
        <!-- <i class="el-icon-close" @click="handleCloseDialogUpdate"></i> -->
      </div>
      <div class="con">
        <div v-for="(item,index) in modifyPwd" :key="index" class="con-row flex flexac pl">
          <div class="marginAuto flex flexac">
            <div class="inputLable inputLable1 flex flexac pre">
              <span class="name texttr"><span class="mustval">*</span>{{ item.name }}：</span>
              <el-input v-model="item.pwd" class="input" :placeholder="item.placeholder" :type="item.pwdshow?'text':'password'" />
              <span class="iconfont pwdshowBtn" :class="item.pwdshow?'icon-yanjing':'icon-mima-yincang-shuru'" @click="item.pwdshow=!item.pwdshow" />
            </div>
          </div>
        </div>
      </div>
      <div class="flex footer footerBtn m-t-35">
        <el-button class="btn left-btn el-icon-circle-check" type="success" @click="handleSave">更 新</el-button>
        <!-- <el-button class="btn clsoeBtn el-icon-circle-close" @click="handleCloseDialogUpdate">关闭</el-button> -->
      </div>
    </div>
  </div>
</template>

<script>

import { changePass } from '@/api/baseInfo/authority/user'
import { showNotice } from '@/utils/toolclass'
import storage from '@/utils/storage'
import { changewx } from '@/api/baseInfo/authority/user'
import { wXGetOpenId } from '@/api/user'

export default {
  components: {},
  props: {
    addFactory: {
      type: Object,
      default: () => ({})
    },
    isEdit: {
      type: Boolean
    }
  },
  data() {
    return {
      modifyPwd: [
        { name: '当前密码', pwd: '', pwdshow: false, placeholder: '请输入当前密码' },
        { name: '新密码', pwd: '', pwdshow: false, placeholder: '请输入新密码' },
        { name: '确认密码', pwd: '', pwdshow: false, placeholder: '请再次输入新密码' }
      ]

    }
  },
  created() {
    this.userInfo = JSON.parse(storage.get('userInfo'))
  },
  mounted() {
    this.$storage.set('upUrl', JSON.stringify({ 'path': '/modifyPwd' }))
  },
  methods: {
    handleSave() {
      // console.log(this.userInfo)
      const newpass = this.modifyPwd[1].pwd + '{' + this.userInfo.mobile + '}'
      const oldpass = this.modifyPwd[0].pwd + '{' + this.userInfo.mobile + '}'
      const md5newpass = this.$md5(newpass)
      const md5oldpass = this.$md5(oldpass)
      changePass(md5newpass, md5oldpass).then(res => {
        // console.log(res)
        if (res.code === '000000') {
          showNotice('success', '提示', '密码修改成功')
        } else {
          if (res.msg === '失败') {
            showNotice('error', '提示', '密码修改失败')
          } else {
            showNotice('error', '提示', res.msg)
          }
        }
      })
    }
  }
}
</script>

<style rel='stylesheet/scss' lang='scss' scoped>
@import "@/styles/addtable.scss";
.btn {
  width: 100px;
  height: 40px;
}
.footer {
  margin-left: -10px;
}
.left-btn {

}
.con {
  padding-left: 50px;
  margin-top: 30px;
  .con-row {
    padding: 15px 0px;
  }
  .inputLable .input {
    height: 36px;
  }
}
.inputLable input {
  width: 450px;
}
.inputLable .name {
  width: 190px !important;
  padding-right: 20px;
}
.pwdshowBtn{
  position: absolute;
  right: 9px;
  cursor: pointer;
}
</style>
